﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test2
{
    class Program
    {
        static void Main(string[] args)
        {
            int max, min, sum;
            double avg;
            Console.Write("请输入多个整数(以空格隔开):");
            string[] sArray = Console.ReadLine().Split(new char[] { ' ' }[0]);
            int[] nums = new int[sArray.Length];
            for(int i = 0; i < sArray.Length; ++i)
            {
                nums[i] = Int32.Parse(sArray[i]);
            }
            getResult(nums, out max, out min, out avg, out sum);
            Console.WriteLine($"最大值:{max},最小值:{min},平均值:{avg},总和:{sum}");
            Console.ReadKey();
        }
        /**
         * 计算数组的最大值，最小值，平均值，总和
         */
        public static void getResult(int[] nums, out int max, out int min, out double avg, out int sum)
        {
            int maxNum = 0, minNum = 65535;
            int sumNum = 0;
            foreach(int i in nums)
            {
                if (i > maxNum)
                {
                    maxNum = i;
                }
                if (i < minNum)
                {
                    minNum = i;
                }
                sumNum += i;
            }
            avg = (double)sumNum / nums.Length;
            max = maxNum;
            min = minNum;
            sum = sumNum;
        }
    }
}
